import type {DbTable} from "@/api/datasource/type.ts";
import request from "@/utils/http.ts";
import type {AxiosResponse} from "axios";


/**
 * 生成单表代码
 *
 * @param data {LoginData}
 * @returns
 */
export function genCodeByTableApi(data: DbTable): Promise<AxiosResponse> {
    const requestJsonData = JSON.stringify(data)
    return request({
        url: "/generate/genCodeByTable",
        method: "post",
        data: requestJsonData,
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
        responseType: "blob",
    });
}

/**
 * 生成多表代码
 *
 * @param data {LoginData}
 * @returns
 */
export function genCodeByTablesApi(data: DbTable[]): Promise<AxiosResponse> {
    const requestJsonData = JSON.stringify(data)
    return request({
        url: "/generate/genCodeByTables",
        method: "post",
        data: requestJsonData,
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
        responseType: "blob",
    });
}


